package com.exam.bean.subject;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * 试题选项
 *
 */
@Entity()
public class OptionItem implements Serializable{
	
	private static final long serialVersionUID = 7386239255400580339L;

	private Integer id;
	private String options;//选项
	private String item;//选项内容
	private Question itemquestion;//试题
	
	public OptionItem() {}

	public OptionItem(Integer id) {
		this.id = id;
	}

	public OptionItem( String item,String options) {
		this.options = options;
		this.item = item;
	}

	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}

	@Column(length=4,nullable=false)
	public String getOptions() {
		return options;
	}
	public void setOptions(String options) {
		this.options = options;
	}

	@Column(length=400,nullable=false)
	public String getItem() {
		return item;
	}
	public void setItem(String item) {
		this.item = item;
	}

 	@ManyToOne(cascade={CascadeType.MERGE, CascadeType.REFRESH }, optional = false)
 	@JoinColumn(name="itemid")
 	public Question getItemquestion() {
 		return itemquestion;
 	}
	public void setItemquestion(Question itemquestion) {
		this.itemquestion = itemquestion;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		OptionItem other = (OptionItem) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
	
	
}
